
<template>
    <el-form ref="form" :model="form" label-width="80px" >
        <el-form-item label="催收方式">
        <!-- <el-radio-group v-model="form.way">
            <el-radio v-for="item in way_list.way" :label="item.id">{{item.name}}</el-radio>
        </el-radio-group> -->
        <el-checkbox-group v-model="form.way" >
            <el-checkbox v-for="item in way_list.way" :label="item.id" :key="item.name">{{item.name}}</el-checkbox>
        </el-checkbox-group>
        </el-form-item>
        <el-form-item label="催收结果">
        <el-checkbox-group v-model="form.result">
            <!-- <el-radio v-for="item in way_list.result" :label="item.id">{{item.name}}</el-radio> -->
            <el-checkbox v-for="item in way_list.result" :label="item.id" :key="item.name">{{item.name}}</el-checkbox>
        </el-checkbox-group>
        </el-form-item>
        <el-form-item label="备注信息">
        <el-input type="textarea" v-model="form.desc"></el-input>
        </el-form-item>
        <!-- <el-form-item label="设置提醒">
           <el-input v-model="form.notice_day" type="number" style="width:70px;"></el-input>  天后提醒我
        </el-form-item> -->
        <el-form-item>
        <el-button type="primary" @click="onSubmit">保存</el-button>
        <el-button @click="cancel">取消</el-button>
        </el-form-item>
    </el-form>
</template>
<script>
    import {
        collectRecordAdd,
        getCollectWay,
    } from '@/api/collection'
    
    export default {
        name: 'collectForm',
        props: ['order_id'],
        created() {
            this.getWay()
        },
        data() {
            return {
                addDescMore:' ',
                tableRecord: 1,
                listRecordLoading: true,
                listLoading: true,
                downloadLoading: false,
                way_list:[],
                form: {
                    way: [],
                    result:[],
                    notice_day:0,
                    desc: '',
                    order_id:this.order_id
                },
            }
        },
        methods:{
            getWay(){
                getCollectWay().then(response => {
                this.way_list = response.data
                })
            },
            onSubmit(){
                if(this.form.way==''||this.form.result==''){
                    this.$notify({
                        title: '提示',
                        message: '请完善信息',
                        type: 'warning',
                        duration:2000
                    });
                    return;
                }
                collectRecordAdd(this.form).then(response => {
                    if(response.code==200){
                        this.$notify({
                            title: '提示',
                            message: '保存成功',
                            type: 'success',
                            duration:2000
                        });
                        this.form.way = [];
                        this.form.result = '';
                        this.form.desc = '';
                        this.$emit('cancel','');
                    }
                    this.listLoading = false
                })
            },
            cancel(){
                this.$emit('cancel','');
            }
            
        }
    }
</script>
<style>
.collectcss{margin-top:7px;color:#999;font-size:14px}
.el-table .warning-row {
      background: orangered;
    }

  .el-table .success-row {
    background: #98dd72;
  }
</style>